package org.jeecg.modules.hc.enums;

import java.util.Arrays;
import java.util.Optional;

public enum HcAliPayStateEnum {
    WAIT_BUYER_PAY("WAIT_BUYER_PAY", "交易创建，等待买家付款"),
    TRADE_CLOSED("TRADE_CLOSED", "未付款交易超时关闭，或支付完成后全额退款"),
    TRADE_SUCCESS("TRADE_SUCCESS", "交易支付成功"),
    TRADE_FINISHED("TRADE_FINISHED", "交易结束，不可退款"),
    ;

    private String value;
    private String name;

    public static String get(String val) {
        Optional<HcAliPayStateEnum> first = Arrays.stream(HcAliPayStateEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.map(HcAliPayStateEnum::getName).orElse(null);
    }

    public static HcAliPayStateEnum getEnum(String val) {
        Optional<HcAliPayStateEnum> first = Arrays.stream(HcAliPayStateEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.orElse(null);
    }

    HcAliPayStateEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
